package com.csxy.six.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.csxy.six.entity.UserAnnouncement;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

@Mapper
public interface UserAnnouncementMapper extends BaseMapper<UserAnnouncement> {
    /**
     * 批量插入用户公告关联
     * @param list 关联列表
     *
     */
    @Insert("<script>" +
            "INSERT INTO user_announcement (user_id, announce_id, notified_at) VALUES " +
            "<foreach collection='list' item='item' separator=','>" +
            "(#{item.userId}, #{item.announceId}, NOW())" +
            "</foreach>" +
            "</script>")
    int batchInsert(@Param("list") List<UserAnnouncement> list);
}
